package com.javatech.config;

import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.reactive.function.client.WebClient;

import java.time.Duration;

/**
 * the ConfigBean
 *
 * @author java-tech
 * @date 2025-03-04
 */
@Configuration
public class ConfigBean {

    @Bean
    public WebClient webClient(WebClient.Builder WebClientBuilder) {
        return WebClientBuilder.baseUrl("http://localhost:3001/api")
                .defaultHeader("Authorization", "Bearer J8E4WEK-70Q46XH-Q7TFGE3-GNAE0DQ")
                .build();
    }

    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder builder) {
        return builder.setConnectTimeout(Duration.ofSeconds(60))
                .setReadTimeout(Duration.ofSeconds(60))
                .build();
    }

}
